import request from "@/utils/request";

// 查询培训列表
export function listTraining(query) {
  return request({
    url: "/system/training/list",
    method: "get",
    params: query,
  });
}

// 查询培训详细
export function getTraining(trainingId) {
  return request({
    url: "/system/training/" + trainingId,
    method: "get",
  });
}

// 新增培训
export function addTraining(data) {
  return request({
    url: "/system/training",
    method: "post",
    data: data,
  });
}

// 修改培训
export function updateTraining(data) {
  return request({
    url: "/system/training",
    method: "put",
    data: data,
  });
}

// 删除培训
export function delTraining(trainingId) {
  return request({
    url: "/system/training/" + trainingId,
    method: "delete",
  });
}

// 封面上传接口
export function uploadTrainingImage(trainingId, file) {
  const formData = new FormData();
  formData.append("file", file);
  return request({
    url: `/system/training/uploadImage/${trainingId}`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formData,
  });
}
